package com.cowin.sys.dao;

import com.cowin.base.Mapper;
import com.cowin.sys.model.TmVhcVehicle;
import com.cowin.sys.model.VehicleImpress;
import com.cowin.sys.model.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface TmVhcVehicleMapper extends Mapper<TmVhcVehicle> {
    /**
     * 功能描述: hold车辆查询<br>
     *
     * @param holdVehicle hold车辆
     * @return:
     * @since: 1.0.0
     * @Author:yuchao
     * @Date: 2019/9/24 14:09
     */
    List<TmVhcVehicle> searchHoldVehicle(HoldVehicle holdVehicle);

    /**
     * 功能描述: 根据Vin号 获取车辆信息<br>
     *
     * @param vinNo vinNo
     * @return:
     * @since: 1.0.0
     * @Author:yuchao
     * @Date: 2019/11/20 15:07
     */
    @Select("SELECT * FROM TM_VHC_VEHICLE where vin = #{vinNo}")
    TmVhcVehicle findByVinNo(String vinNo);

    /**
     * 功能描述: 获取颜色<br>
     *
     * @param
     * @return:
     * @since: 1.0.0
     * @Author:yuchao
     * @Date: 2019/11/30 13:32
     */
    @Select("SELECT 1 type,FEATURE_CODE value ,COLOR_BASE_DESCRIPTION valueEx FROM TM_BAS_CHECKOUT_COLOR")
    List<VehicleImpress> getColor();

    @Select("SELECT FEATURE_CODE codeValue ,COLOR_BASE_DESCRIPTION name FROM TM_BAS_CHECKOUT_COLOR")
    List<SysCodeVo> findVehicleColorConfig();

    /**
     * 功能描述: 获取 2：天窗，3：左右舵，4：高亮膜，5：EV，6：计划类型 <br>
     *
     * @param
     * @return:
     * @since: 1.0.0
     * @Author:yuchao
     * @Date: 2019/12/4 14:51
     */
    @Select("SELECT TC_SYS_CODE_LIST.CODE_VALUE  type ,TM_BAS_FEATURE_ITEM.FEATURE_ITEM_NO value,TM_BAS_FEATURE_ITEM.FEATURE_ITEM_DESC valueEx  FROM TC_SYS_CODE_LIST left join TC_SYS_CODE_TYPE  on TC_SYS_CODE_LIST.TC_SYS_CODE_TYPE_ID=TC_SYS_CODE_TYPE.TC_SYS_CODE_TYPE_ID left join  TM_BAS_FEATURE on TM_BAS_FEATURE.FEATURE_NO=TC_SYS_CODE_LIST.CODE_VALUE_DESC_C\n" +
            "\tleft join TM_BAS_FEATURE_ITEM on  TM_BAS_FEATURE_ITEM.TM_BAS_FEATURE_ID=TM_BAS_FEATURE.TM_BAS_FEATURE_ID\n" +
            "  where TC_SYS_CODE_TYPE.CODE_TYPE='Key_Configure_Filed'")
    List<VehicleImpress> getFeatureItem();

    /**
     * 功能描述:获取车型 <br>
     *
     * @param
     * @return:
     * @since: 1.0.0
     * @Author:yuchao
     * @Date: 2019/12/4 15:05
     */
    @Select("select distinct vehicle_Type as value, vehicle_Type as valueEX ,0 type from Tm_Bas_Material_Relation")
    List<VehicleImpress> getVehicleType();

    /**
     * 功能描述: 查询过点信息<br>
     *
     * @param
     * @return:
     * @since: 1.0.0
     * @Author:yuchao
     * @Date: 2020/3/17 11:14
     */
    @Select("SELECT count(1) as count  FROM TM_VHC_VEHICLE_MOVEMENT   left join TM_VHC_VEHICLE on TM_VHC_VEHICLE_MOVEMENT.TM_VHC_VEHICLE_ID=TM_VHC_VEHICLE.TM_VHC_VEHICLE_ID\n" +
            "left join TM_BAS_ULOC on TM_VHC_VEHICLE_MOVEMENT.TM_BAS_ULOC_ID = TM_BAS_ULOC.TM_BAS_ULOC_ID\n" +
            "where TM_VHC_VEHICLE_MOVEMENT.TM_BAS_ULOC_ID in (SELECT\n" +
            "TM_BAS_ULOC.TM_BAS_ULOC_ID\n" +
            "FROM\n" +
            "\tTC_SYS_CODE_LIST LEFT JOIN TM_BAS_ULOC ON TC_SYS_CODE_LIST.CODE_VALUE_DESC_E = TM_BAS_ULOC.ULOC_NO left join TC_SYS_CODE_TYPE ON TC_SYS_CODE_LIST.TC_SYS_CODE_TYPE_ID = TC_SYS_CODE_TYPE.TC_SYS_CODE_TYPE_ID\n" +
            "WHERE\n" +
            "\tTC_SYS_CODE_TYPE.CODE_TYPE = 'Key_Point_Position'\n" +
            "\tAND TC_SYS_CODE_LIST.CODE_VALUE = #{codeValue})   and TM_VHC_VEHICLE.VIN=#{vin}")
    Integer findCountAtPointByVin(@Param("codeValue") String codeValue, @Param("vin") String vin);


    /**
     * 功能描述: <br>
     *  <根据焊装10 20 涂装10 20 总装 10 20 30点位 查询在制车辆信息 >
     * @param:
     * @return:
     * @author:yuchao
     * @date: 2020/3/20 13:42
     */
    List<OnLineMakeVehicle> onLineMakeByPoint(@Param("point") String point,@Param("vin") String vin);

    /**
     * 功能描述: <br>
     *  <VIN、白车身号、白车身物料号、油漆车身物料号、整车物料号、整车物料描述、颜色、车辆公告号、生产批次号、生产订单号、销售类型、加工类型、出口国家>
     * @param:车辆细节查询过滤  查询条件：销售类型、物料号、批次号、扫描点&扫描点开始与结束时间(不大于30天)
     * @return:
     * @author:yuchao
     * @date: 2020/3/31 14:48
     */
    List<VehicleDetails> findVehicleDetails(VehicleDetails vehicleDetails);

    /**
     * 功能描述: <br>
     *  <获取车型配置。>
     * @param:
     * @return:
     * @author:yuchao
     * @date: 2020/4/1 12:47
     */
    @Select("select distinct vehicle_Type as codeValue, vehicle_Type as name  from Tm_Bas_Material_Relation")
    List<SysCodeVo>  findVehicleType();
}